import pandas as pd
import random

# # 读取CSV文件
# df = pd.read_csv(r'd:\许世荣\code\first_python\code_python\爬虫\test2.csv')

# # 只保留第一列和最后一列
# df_filtered = df[['location', 'comments']]

# # 打乱每一行的顺序
# df_filtered = df_filtered.sample(frac=1).reset_index(drop=True)

# # 随机抽取两千条数据添加至末尾
# df_sampled = df_filtered.sample(n=2000, replace=True)
# df_filtered = pd.concat([df_filtered, df_sampled], ignore_index=True)

# # 保存到新的CSV文件
# df_filtered.to_csv(r'd:\许世荣\code\first_python\code_python\爬虫\test3.csv', index=False)


# 读取test1.csv文件
df_test1 = pd.read_csv(r'd:\许世荣\code\first_python\code_python\爬虫\test1.csv')

# 只保留地址列和评论列，并调整列的顺序
df_test1_filtered = df_test1[['location', 'comments']]

# 保存到新的CSV文件
df_test1_filtered.to_csv(r'd:\许世荣\code\first_python\code_python\爬虫\test1_processed.csv', index=False)